USE [master]
GO

/****** Object:  Database [tp-Telefonia2012]    Script Date: 10/18/2012 14:27:20 ******/
CREATE DATABASE [tp-Telefonia2012] ON  PRIMARY 
( NAME = N'tp-Telefonia2012', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tp-Telefonia2012.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'tp-Telefonia2012_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tp-Telefonia2012_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [tp-Telefonia2012] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [tp-Telefonia2012].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [tp-Telefonia2012] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET ARITHABORT OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [tp-Telefonia2012] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [tp-Telefonia2012] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [tp-Telefonia2012] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET  DISABLE_BROKER 
GO

ALTER DATABASE [tp-Telefonia2012] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [tp-Telefonia2012] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [tp-Telefonia2012] SET  READ_WRITE 
GO

ALTER DATABASE [tp-Telefonia2012] SET RECOVERY FULL 
GO

ALTER DATABASE [tp-Telefonia2012] SET  MULTI_USER 
GO

ALTER DATABASE [tp-Telefonia2012] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [tp-Telefonia2012] SET DB_CHAINING OFF 
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Consumos]    Script Date: 10/18/2012 14:27:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Consumos](
	[nroConsumo] [int] NOT NULL,
	[nroLinea] [varchar](50) NOT NULL,
	[fecha] [datetime] NOT NULL,
	[tipoServicio] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Consumos] PRIMARY KEY CLUSTERED 
(
	[nroConsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Consumos]  WITH CHECK ADD  CONSTRAINT [FK_Consumos_LineasAdicional] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[LineasAdicional] ([nroLineaAd])
GO

ALTER TABLE [dbo].[Consumos] CHECK CONSTRAINT [FK_Consumos_LineasAdicional]
GO

ALTER TABLE [dbo].[Consumos]  WITH CHECK ADD  CONSTRAINT [FK_Consumos_Lineass] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[Lineass] ([nroLinea])
GO

ALTER TABLE [dbo].[Consumos] CHECK CONSTRAINT [FK_Consumos_Lineass]
GO
USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Consumos]    Script Date: 10/18/2012 14:27:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Consumos](
	[nroConsumo] [int] NOT NULL,
	[nroLinea] [varchar](50) NOT NULL,
	[fecha] [datetime] NOT NULL,
	[tipoServicio] [varchar](50) NOT NULL,
 CONSTRAINT [PK_Consumos] PRIMARY KEY CLUSTERED 
(
	[nroConsumo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Consumos]  WITH CHECK ADD  CONSTRAINT [FK_Consumos_LineasAdicional] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[LineasAdicional] ([nroLineaAd])
GO

ALTER TABLE [dbo].[Consumos] CHECK CONSTRAINT [FK_Consumos_LineasAdicional]
GO

ALTER TABLE [dbo].[Consumos]  WITH CHECK ADD  CONSTRAINT [FK_Consumos_Lineass] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[Lineass] ([nroLinea])
GO

ALTER TABLE [dbo].[Consumos] CHECK CONSTRAINT [FK_Consumos_Lineass]
GO


USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Facturas]    Script Date: 10/18/2012 14:28:19 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Facturas](
	[nroFactura] [varchar](50) NOT NULL,
	[nroLinea] [varchar](50) NOT NULL,
	[periodoFacturado] [varchar](50) NOT NULL,
	[estado] [varchar](10) NOT NULL,
	[vencimiento] [datetime] NOT NULL,
	[totalFacturado] [float] NOT NULL,
 CONSTRAINT [PK_Facturas] PRIMARY KEY CLUSTERED 
(
	[nroFactura] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Facturas]  WITH CHECK ADD  CONSTRAINT [FK_Facturas_LineasAdicional] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[LineasAdicional] ([nroLineaAd])
GO

ALTER TABLE [dbo].[Facturas] CHECK CONSTRAINT [FK_Facturas_LineasAdicional]
GO

ALTER TABLE [dbo].[Facturas]  WITH CHECK ADD  CONSTRAINT [FK_Facturas_Lineass] FOREIGN KEY([nroLinea])
REFERENCES [dbo].[Lineass] ([nroLinea])
GO

ALTER TABLE [dbo].[Facturas] CHECK CONSTRAINT [FK_Facturas_Lineass]
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[ItemFacturas]    Script Date: 10/18/2012 14:28:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ItemFacturas](
	[idItemF] [int] NOT NULL,
	[nroFactura] [varchar](50) NOT NULL,
	[nombreServicio] [varchar](50) NOT NULL,
	[excedido] [bit] NOT NULL,
	[cantidad] [float] NOT NULL,
	[precioUnitario] [float] NOT NULL,
	[precioFinal] [float] NOT NULL,
 CONSTRAINT [PK_ItemFacturas] PRIMARY KEY CLUSTERED 
(
	[idItemF] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[ItemFacturas]  WITH CHECK ADD  CONSTRAINT [FK_ItemFacturas_Facturas] FOREIGN KEY([nroFactura])
REFERENCES [dbo].[Facturas] ([nroFactura])
GO

ALTER TABLE [dbo].[ItemFacturas] CHECK CONSTRAINT [FK_ItemFacturas_Facturas]
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[LineasAdicional]    Script Date: 10/18/2012 14:28:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[LineasAdicional](
	[nroLineaAd] [varchar](50) NOT NULL,
	[dniUsuario] [varchar](8) NOT NULL,
	[idPlan] [varchar](50) NOT NULL,
	[fechaContrato] [datetime] NOT NULL,
	[estado] [varchar](10) NOT NULL,
	[nroLineaTitular] [varchar](50) NOT NULL,
	[nombreAdicional] [varchar](50) NOT NULL,
	[fechaUltLiq] [datetime] NOT NULL,
	[fechaProxLiq] [datetime] NOT NULL,
 CONSTRAINT [PK_LineasAdicional] PRIMARY KEY CLUSTERED 
(
	[nroLineaAd] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[LineasAdicional]  WITH CHECK ADD  CONSTRAINT [FK_LineasAdicional_Planes] FOREIGN KEY([idPlan])
REFERENCES [dbo].[Planes] ([nroPlan])
GO

ALTER TABLE [dbo].[LineasAdicional] CHECK CONSTRAINT [FK_LineasAdicional_Planes]
GO

ALTER TABLE [dbo].[LineasAdicional]  WITH CHECK ADD  CONSTRAINT [FK_LineasAdicional_Usuarios] FOREIGN KEY([dniUsuario])
REFERENCES [dbo].[Usuarios] ([dni])
GO

ALTER TABLE [dbo].[LineasAdicional] CHECK CONSTRAINT [FK_LineasAdicional_Usuarios]
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Lineass]    Script Date: 10/18/2012 14:28:52 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Lineass](
	[nroLinea] [varchar](50) NOT NULL,
	[dniUsuario] [varchar](8) NOT NULL,
	[nroPlan] [varchar](50) NOT NULL,
	[fechaContrato] [datetime] NOT NULL,
	[estado] [nchar](10) NOT NULL,
	[fechaUltLiq] [datetime] NOT NULL,
	[fechaProxLiq] [datetime] NOT NULL,
 CONSTRAINT [PK_Lineass] PRIMARY KEY CLUSTERED 
(
	[nroLinea] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Lineass]  WITH CHECK ADD  CONSTRAINT [FK_Lineass_Planes] FOREIGN KEY([nroPlan])
REFERENCES [dbo].[Planes] ([nroPlan])
GO

ALTER TABLE [dbo].[Lineass] CHECK CONSTRAINT [FK_Lineass_Planes]
GO

ALTER TABLE [dbo].[Lineass]  WITH CHECK ADD  CONSTRAINT [FK_Lineass_Usuarios] FOREIGN KEY([dniUsuario])
REFERENCES [dbo].[Usuarios] ([dni])
GO

ALTER TABLE [dbo].[Lineass] CHECK CONSTRAINT [FK_Lineass_Usuarios]
GO


USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Planes]    Script Date: 10/18/2012 14:29:00 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Planes](
	[nroPlan] [varchar](50) NOT NULL,
	[estado] [varchar](50) NOT NULL,
	[precio] [float] NOT NULL,
	[tipo] [varchar](50) NOT NULL,
	[valorMinExcedente] [float] NOT NULL,
	[minutosLibres] [float] NOT NULL,
 CONSTRAINT [PK_Planes] PRIMARY KEY CLUSTERED 
(
	[nroPlan] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Servicioss]    Script Date: 10/18/2012 14:29:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Servicioss](
	[idServicio] [int] NOT NULL,
	[nroPlan] [varchar](50) NOT NULL,
	[nombre] [varchar](50) NOT NULL,
	[estado] [varchar](50) NOT NULL,
	[vigencia] [datetime] NOT NULL,
	[valorUnitario] [float] NOT NULL,
	[valorExcedente] [float] NOT NULL,
	[tipo] [varchar](50) NOT NULL,
	[libres] [float] NOT NULL,
	[idPaquete] [int] NULL,
 CONSTRAINT [PK_Servicioss] PRIMARY KEY CLUSTERED 
(
	[idServicio] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Servicioss]  WITH CHECK ADD  CONSTRAINT [FK_Paquetes_Servicios] FOREIGN KEY([idServicio])
REFERENCES [dbo].[Servicioss] ([idServicio])
GO

ALTER TABLE [dbo].[Servicioss] CHECK CONSTRAINT [FK_Paquetes_Servicios]
GO

ALTER TABLE [dbo].[Servicioss]  WITH CHECK ADD  CONSTRAINT [FK_Servicioss_Planes] FOREIGN KEY([nroPlan])
REFERENCES [dbo].[Planes] ([nroPlan])
GO

ALTER TABLE [dbo].[Servicioss] CHECK CONSTRAINT [FK_Servicioss_Planes]
GO

USE [tp-Telefonia2012]
GO

/****** Object:  Table [dbo].[Usuarios]    Script Date: 10/18/2012 14:29:19 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Usuarios](
	[dni] [varchar](8) NOT NULL,
	[nombre] [varchar](50) NOT NULL,
	[apellido] [varchar](50) NOT NULL,
	[domicilio] [varchar](10) NOT NULL,
	[telefono] [varchar](50) NULL,
	[email] [varchar](50) NULL,
 CONSTRAINT [PK_Usuarios] PRIMARY KEY CLUSTERED 
(
	[dni] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

